import request from '@/utils/request'

/**
 * @desc 获取购物车列表
 * @returns Promise
 */
export const getShopCarData = () => {
  return request({
    method: 'GET',
    url: '/api/cart/cartList'
  })
}

/**
 * @desc 切换商品选中状态
 * @returns Promise
 */

export const getChangeData = (skuID, isChecked) => {
  return request({
    method: 'GET',
    url: `/api/cart/checkCart/${skuID}/${isChecked}`
  })
}

/**
 * @desc 购物车商品全选
 * @param skuIdList 代表修改的商品id
 * @param isChecked 最新的状态
 * @returns Promise
 */
export const allSelect = (skuIdList, isChecked) => {
  return request.post(`/api/cart/batchCheckCart/${isChecked}`, skuIdList)
}

/**
 * @desc 删除单个物品
 * @param id 删除购物车单个商品id
 * @returns Promise
 */
export const deleteIndividual = (id) => {
  return request({
    method: 'delete',
    url: `/api/cart/deleteCart/${id}`
  })
}

export const deleteSelected = (list) => {
  return request({
    method: 'POST',
    url: '/api/cart/batchDeleteCart',
    data: list
  })
}
